﻿function showTime() {
    var currentTime = new Date();
    var year = currentTime.getFullYear();
    var month = currentTime.getMonth() + 1;
    var date = currentTime.getDate();
    var day = currentTime.getDay();
    var hours = currentTime.getHours();
    var minutes = currentTime.getMinutes();
    var seconds = currentTime.getSeconds();
    var time = document.getElementById("currentTime");
    if (seconds < 10) {
        seconds = "0" + seconds;
    }
    if (minutes < 10) {
        minutes = "0" + minutes;
    }
    time.innerHTML = year + "年" + month + "月" + date + "日   " + hours + " : " + minutes + " : " + seconds;
};


function searchTime() {
    var selectedYear = $('#searchYear').val();
    var currentTime = new Date();
    $('#searchYear').empty();
    document.getElementById('searchYear').options.add(new Option(currentTime.getFullYear(), currentTime.getFullYear()));
    document.getElementById('searchYear').options.add(new Option(currentTime.getFullYear() - 1, currentTime.getFullYear() - 1));
    if (selectedYear == null) {
        $('#searchYear').val(currentTime.getFullYear());
    } else {
        $('#searchYear').val(selectedYear);
    }
    $('#searchMonth').empty();
    for (var i = 1; i <= 12; i++) {
        if ($('#searchYear').val() == currentTime.getFullYear()) {
            if (i <= currentTime.getMonth() + 1) {
                document.getElementById('searchMonth').options.add(new Option(i < 10 ? '0' + i : i, i < 10 ? '0' + i : i));
            }
        } else {
            document.getElementById('searchMonth').options.add(new Option(i < 10 ? '0' + i : i, i < 10 ? '0' + i : i));
        }
    }
};